package com.qf.eduadmin.controller;

import com.qf.eduadmin.pojo.vo.QfTeach;
import com.qf.eduadmin.pojo.resp.ResponseData;
import com.qf.eduadmin.service.QfTeachService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (QfTeach)表控制层
 *
 * @author makejava
 * @since 2021-12-25 17:15:56
 */
@RestController
@RequestMapping("/qfTeach")
public class QfTeachController {
    /**
     * 服务对象
     */
    @Resource
    private QfTeachService qfTeachService;

    @RequestMapping("/findAll")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/findAll"})
    public ResponseData findAll(@RequestParam("page")Integer page,@RequestParam("limit")Integer limit){
        //System.out.println(page+"---"+limit);
        ResponseData responseData = qfTeachService.queryAllByLimit(page,limit);
        return responseData;
    }

    @RequestMapping("/insertTeacher")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/insertTeacher"})
    public ResponseData insertTeacher(@RequestBody QfTeach qfTeach){
       // System.out.println(qfTeach);
        ResponseData responseData = qfTeachService.insert(qfTeach);
        return responseData;
    }

    @RequestMapping("/deleteTeacher/{id}")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/deleteTeacher/{id}"})
    public ResponseData deleTeacher(@PathVariable("id") Integer id){
        ResponseData responseData = qfTeachService.deleteById(id);
        return responseData;
    }

    @RequestMapping("/findById")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/findById"})
    public ResponseData findById(@RequestParam("id")Integer id){
        //System.out.println(id);
        ResponseData responseData = qfTeachService.queryById(id);
        return responseData;
    }

    @RequestMapping("/updateTeacher")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/updateTeacher"})
    public ResponseData updateTeacher(@RequestBody QfTeach qfTeach){
        System.out.println(qfTeach);
        ResponseData responseData = qfTeachService.update(qfTeach);
        return responseData;
    }

    @RequestMapping("/findAllTeacher")
    @RequiresAuthentication
    @RequiresPermissions(value = {"/qfTeach/findAllTeacher"})
    public ResponseData findAllTeacher(){
        ResponseData responseData = qfTeachService.findAllTeacher();
        return responseData;
    }
}